<?php

$action = getAction();

switch ($action) {
	case "index":
		if($subscribe) {
			$smarty->display("getWebTraffic_yes.html");
		} else {
			$smarty->display("getWebTraffic_yes.html");
// 			$smarty->display("getWebTraffic_no.html");
		}
		break;
	case "jpost":
		$data["phone"] = $_POST["phone"];
		$data["name"] = $_POST["name"];
		
		$result = array();
		if(!$data["phone"]) {
			$result["errmsg"] = "请输入手机号码";
		} else if (!$data["name"]) {
			$result["errmsg"] = "请输入姓名";
		}
		
		//判断是否申报过此次活动
		$check = $db->getOne("select count(1) from " . table("give_order") . " where openid = '$openid'");
		
		if($check) {
			$result["errmsg"] = "一个微信号只能申请一次";
		}
		
		if($result["errmsg"]) {
			echo json_encode($result);
			exit();
		}
		
		$data["openid"] = $openid;
		$data["status"] = "01";
		$data["insert_time"] = getNowTime();
		$data["update_time"] = getNowTime();
		
		$db->insert("give_order", $data);
		$result["succ"] = true;
		echo json_encode($result);
		break;
}
?>